<html>
  <head>
    <title>Example</title>
  </head>
  <body>
    <div id="app"></div>

    <script>
      // 结论：扩展运算法放到函数的参数中的时候，会把参数转换为对应的类数组，然后可以对该数组进行操作
      function sum(...numbers) {
        let total = 0;
        numbers.forEach((number) => {
          total += number;
        });
        return total;
      }

      const app = document.getElementById("app");
      const element = document.createElement("h1");
      element.textContent = `Sum: ${sum(1, 2, 3, 4)}`;
      app.appendChild(element);
    </script>
  </body>
</html>
